import { z } from "zod"

export const SessionSchema = {
  id: "",
  conversationID: "",
  toAccount: "",
  type: "",
  subType: "",
  lastMessage: {},
  unreadCount: 0,
  peerReadTime: 0,
  groupAtInfoList: [],
  groupProfile: {},
  userProfile: {
    userID: "",
    nick: "",
    gender: "",
    birthday: 0,
    location: "",
    selfSignature: "",
    allowType: "",
    language: 0,
    avatar: "",
    messageSettings: 0,
    adminForbidType: "",
    level: 0,
    role: 0,
    lastUpdatedTime: 0,
    profileCustomField: [],
  },
  remark: "",
  isPinned: false,
  pinned: 0,
  messageRemindType: "",
  markList: [],
  customData: "",
  conversationGroupList: [],
  draftText: "",
  createdAt: 0,
  updatedAt: 0,
}

export const DB_SessionSchema = z.object({
  id: z.string().optional(),
  conversationID: z.string(),
  toAccount: z.string().optional(),
  type: z.enum(["C2C", "GROUP", "SYSTEM"]),
  subType: z.string().optional(),
  lastMessage: z.object({}).optional(),
  unreadCount: z.number().int().min(0).optional(),
  peerReadTime: z.number().optional(),
  groupAtInfoList: z.array(z.any()).optional(),
  groupProfile: z.object({}).optional(),
  userProfile: z
    .object({
      userID: z.string().optional(),
      nick: z.string().optional(),
      gender: z.string().optional(),
      birthday: z.number().optional(),
      location: z.string().optional(),
      selfSignature: z.string().optional(),
      allowType: z.string().optional(),
      language: z.number().optional(),
      avatar: z.string().optional(),
      messageSettings: z.number().optional(),
      adminForbidType: z.string().optional(),
      level: z.number().optional(),
      role: z.number().optional(),
      lastUpdatedTime: z.number().optional(),
      profileCustomField: z.array(z.any()).optional(),
    })
    .optional(),
  remark: z.string().optional(),
  isPinned: z.boolean().optional(),
  pinned: z.number().int().min(0).max(1).optional(),
  messageRemindType: z.string().optional(),
  markList: z.array(z.any()).optional(),
  customData: z.string().optional(),
  conversationGroupList: z.array(z.any()).optional(),
  draftText: z.string().optional(),
  createdAt: z.number().optional(),
  updatedAt: z.number().optional(),
})

export type DB_Session = z.infer<typeof DB_SessionSchema>
